from ..redisbase.redis_operations import (set_hash_data, get_hash_data,
                                        get_hash_field,delete_hash_key,
                                        check_key_exists)
import time

# 获取当前日期
# current_date = time.strftime("%Y-%m-%d", time.localtime())
# print("当前日期:", current_date)
#
# # 存储哈希数据，例如：name:"xiaoxiao",data:"2025-08-17",quantity:12
# hash_data = {
#     "name": "xiaoxiao",
#     "data": "2025-08-17",
#     "quantity": "12"  # Redis中所有值都是字符串类型
# }
#
# # 设置哈希数据
# set_hash_data("user_info", hash_data)
#
# # 获取所有哈希数据
# result = get_hash_data("user_info")
# print("哈希数据:", result)
#
# # 获取特定字段
# name = get_hash_field("user_info", "name")
# print("姓名:", name)
#
# delete_hash_key("user_info")

def user_info_init(id,name,date):
    if not check_key_exists(id):
        hash_data = {
            "name": name,
            "date": date,
            "video_quantity": 0,
            "image_quantity": 0,
            "voice_quantity": 0,
            "ppt_quantity": 0,
            "questions_quantity": 0,
        }
        set_hash_data(id, hash_data)


